﻿using AutoMapper;
using Fake_Shop_WebApi.Dtos;
using Fake_Shop_WebApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Fake_Shop_WebApi.Profiles
{
    public class TouristRoutesProfiles:Profile
    {
        public TouristRoutesProfiles()
        {
            CreateMap<TouristRoute, TouristRouteDto>()
                .ForMember(
                    dist => dist.Price,
                    opt => opt.MapFrom(src => src.OriginalPrice * (decimal)(src.DiscountPresent ?? 1)))
                .ForMember(
                    dist => dist.TravelDays,
                    opt => opt.MapFrom(src => src.TravelDays.ToString()))
                .ForMember(
                    dist => dist.TripType,
                    opt => opt.MapFrom(src => src.TripType.ToString()))
                .ForMember(
                    dist => dist.DepartureCity,
                    opt => opt.MapFrom(src => src.DepartureCity.ToString()));

            CreateMap<TouristRouteForCartionDto,TouristRoute>()
               .ForMember(
                   dest => dest.Id,
                   opt => opt.MapFrom(src => Guid.NewGuid()));
            CreateMap<TouristRouteForUpdateDto, TouristRoute>();
            CreateMap<TouristRoute, TouristRouteForUpdateDto>();
        }
    }
}
